package com.huawei.appmarket.service.forum;

import android.app.ActionBar;
import android.app.Activity;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.ColorRes;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.BaseTitleBean;
import com.huawei.appmarket.framework.MainActivityBase;
import com.huawei.appmarket.framework.widget.FixedSearchView;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import o.azb;
import o.bus.c;
import o.bvn;
import o.cbc;
import o.cbd;
import o.cjf;
import o.der.g;
import o.Logger;
import o.ContentManager;
import o.dzn;
import o.evf;
import o.evx;
import o.fho;
import o.fjt;
import o.fke;
import o.fkg;

public class ForumMsgSearchTitle extends cjf {
    private TextView ˏ;
    private AtomicBoolean ॱॱ = new AtomicBoolean(false);
    private fkg ᐝ;

    static class d implements Runnable {
        private WeakReference<ForumMsgSearchTitle> ˊ;
        private final String ˎ;

        private d(ForumMsgSearchTitle forumMsgSearchTitle, String str) {
            this.ˊ = new WeakReference(forumMsgSearchTitle);
            this.ˎ = str;
        }

        public void run() {
            ForumMsgSearchTitle forumMsgSearchTitle = (ForumMsgSearchTitle) this.ˊ.get();
            if (forumMsgSearchTitle != null && forumMsgSearchTitle.ˏ != null) {
                if (TextUtils.isEmpty(this.ˎ)) {
                    forumMsgSearchTitle.ˏ.setVisibility(8);
                    return;
                }
                forumMsgSearchTitle.ˏ.setVisibility(0);
                forumMsgSearchTitle.ˏ.setText(this.ˎ);
            }
        }
    }

    public ForumMsgSearchTitle(Activity activity, BaseTitleBean baseTitleBean) {
        super(activity, baseTitleBean);
    }

    public void ॱ() {
        super.ॱ();
        try {
            ˋॱ();
        } catch (Exception e) {
            Logger.e("ForumMsgSearchTitle", "subscribe error");
        }
    }

    public View ʽ() {
        ActionBar actionBar = this.ˋ.getActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        View inflate = this.ˊ.inflate(g.ʼ, null);
        azb.ˏ(inflate);
        int ͺ = ͺ();
        int ॱˊ = ॱˊ();
        if (ͺ > 0) {
            evf.ॱ(inflate, ͺ);
        }
        ˋ(ͺ, ॱˊ);
        FixedSearchView fixedSearchView = (FixedSearchView) inflate.findViewById(o.der.d.ʼʽ);
        fixedSearchView.setTitleBean(this.ˎ);
        fixedSearchView.setIsFromForum(ʼ());
        RelativeLayout relativeLayout = (RelativeLayout) inflate.findViewById(o.der.d.ˎͺ);
        this.ˏ = (TextView) inflate.findViewById(o.der.d.ᵢ);
        relativeLayout.setOnClickListener(new evx(this) {
            final /* synthetic */ ForumMsgSearchTitle ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                if (this.ˊ.ˋ != null) {
                    ((bvn) fho.ˏ().ˋ("Message").ॱ(bvn.class)).ॱ(this.ˊ.ˋ, PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(ContentManager.getInstant().getContext().getPackageName()) ? 0 : 1);
                }
            }
        });
        return inflate;
    }

    private void ˋॱ() {
        Logger.ˎ("ForumMsgSearchTitle", "subscribeUnReadForumMsg");
        ((bvn) fho.ˏ().ˋ("Message").ॱ(bvn.class)).ˊ("forum_msg_search_title" + System.currentTimeMillis()).ˋ(fjt.ˋ(), new fke<HashMap<String, String>>(this) {
            final /* synthetic */ ForumMsgSearchTitle ˊ;

            {
                this.ˊ = r1;
            }

            public void ˎ(fkg o_fkg) {
                Logger.ˎ("ForumMsgSearchTitle", "getTotalUnReadMsg onSubscribe");
                this.ˊ.ᐝ = o_fkg;
                if (this.ˊ.ॱॱ.get()) {
                    this.ˊ.ᐝ.ˋ();
                }
            }

            public void ॱ(HashMap<String, String> hashMap) {
                if (hashMap == null) {
                    Logger.e("ForumMsgSearchTitle", "unReadMsgCountMap is null");
                } else {
                    String str = (String) hashMap.get(c.ˎ);
                    Logger.ˎ("ForumMsgSearchTitle", "getTotalUnReadMsg :" + str);
                    new Handler(Looper.getMainLooper()).post(new d(str));
                }
                cbc ˊ = ((cbd) fho.ˏ().ˋ("User").ॱ(cbd.class)).ˊ();
                if (ˊ != null) {
                    dzn.ॱ(ˊ.ˊ());
                }
            }

            public void ˊ(Exception exception) {
                Logger.ˋ("ForumMsgSearchTitle", "getTotalUnReadMsg onFailure");
            }

            public void ॱ() {
                Logger.ˋ("ForumMsgSearchTitle", "getTotalUnReadMsg onComplete");
            }
        });
    }

    public void ʻ() {
    }

    public String ᐝ() {
        return "forum_msg_search_title";
    }

    public void ॱॱ() {
        super.ॱॱ();
        if (this.ᐝ != null) {
            this.ᐝ.ˋ();
        }
        this.ॱॱ.set(true);
    }

    protected boolean ʼ() {
        return false;
    }

    private int ͺ() {
        if (ˊॱ()) {
            return a.ʻ;
        }
        return a.ˏ;
    }

    @ColorRes
    private int ॱˊ() {
        if (ˊॱ()) {
            return a.ॱ;
        }
        return a.ᐝ;
    }

    private boolean ˊॱ() {
        return MainActivityBase.class.isAssignableFrom(this.ˋ.getClass());
    }
}
